package com;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hnl.test.ImportData;
import com.hnl.test.GenerateTestData;

@SuppressWarnings("serial")
public class HelloWorld extends HttpServlet {
	public static final Logger LOG = LoggerFactory.getLogger(HelloWorld.class);

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String data = req.getParameter("data");

		// goto DB, use name, bla bla bla
		String tmp = "LALALA";
		req.setAttribute("tmp", tmp);
		// RequestDispatcher dispatcher = req
		// .getRequestDispatcher("/pages/helloworld2.jsp");
		// dispatcher.forward(req, r);

		if (data != null) {
			if(data.equals("1")){
				GenerateTestData.main();
			}
			if(data.equals("2")){
				new ImportData().main();
			}

		}

		PrintWriter writer = resp.getWriter();
		writer.println("HelloWorld Successful");
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		super.doPost(req, resp);
	}

}
